Skip to contentSkip to conversation

Raspberry Pi 4B's can0 on dom0

DISCUSSION [email protected] 1 participant 1 message Apr 10, 2024

lore
Share & tools
lore
#0 lore raw

Hi!

I'm creating a custom OS based on Kirkstone.
I want to run it in dom0 on Raspberry Pi 4B device with Xen virtualization enabled. Therefore I include both meta-virtualization and meta-raspberrypi (Kirkstone branch for both).

I attach a PICAN-M HAT ( https://copperhilltech.com/blog/pican2-pican3-and-picanm-driver-installation-for-raspberry-pi/ ) to the Raspberry Pi 4B. I expect the OS to discover the CAN0 device in dom0, but it's not available : Cannot find device "can0".

Using meta-virtualization and meta-raspberrypi layers means that I'm actually using linux-yocto kernel and not linux-raspberrypi. I suspect that there's an issue with the device-tree / kernel configuration of linux-yocto. When I run e.g. 2023-08-04-OpenPlotter-v3-Starting-stable-64bit-img on this device, the problem disappears, i.e. can0 is available.

I know that CAN works via SPI converters on Raspberry Pi 4B, therefore I've added the following lines to my boot/config.txt file that lies on the boot partition on the SD card:
*dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25*

However, the can0 device still cannot be recognized.
Moreover, all SPIs are disabled in the /proc/device-tree when I check them with cat spi\@7e204*/status.

I tried to pull the device-tree file from the 2023-08-04-OpenPlotter-v3-Starting-stable-64bit-img, but the OS doesn't boot up.
I can see that the file from here: https://github.com/raspberrypi/linux/blob/rpi-5.15.y/arch/arm/boot/dts/bcm2711-rpi-4-b.dts (the one I'd expect to compile) is completely different that I've got from the bitbake build directory:./tmp/work-shared/ raspberrypi4-64/kernel-source/ arch/arm/boot/dts/bcm2711-rpi- 4-b.dts.(File attached)

Even if I merge these lines:

Quoted 14 lines

&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;

spidev0: spidev@0{
compatible = "spidev";
reg = <0>; /* CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};

Quoted 9 lines

spidev1: spidev@1{
compatible = "spidev";
reg = <1>; /* CE1 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <125000000>;
};
};

+ include needed .dtsi files, it compiles, but it still doesn't work properly.

Is there any problem with the device-tree?
Do you have any suggestions how to make the OS to recognize CAN0 device from the HAT?